<template>
  <div class="container">
    <data-view
      ref="dataView"
      propViewKey="delivery_crud"
      propViewForm="delivery/detail.vue"
      :propIsTdesign="true"
      :propShowBtnLog="true"
      :propAutoFetchData="false"
      :propPreQueryWrapper = "propPreQueryWrapper"
      :propHideColumns = "propHideColumns"
      @after-load="afterLoad"
      :propFilterBtn="filterBtn"
      :propDisabledLoadFormGetFirst="true"
    />
  </div>
</template>

<script>
export default {
  help: '发货-共用列表',
  props: ['propPreQueryWrapper','propHideColumns', 'propParent'],
  data() {
    return {
      idQuery: '',
    }
  },
  methods: {
    // 加载数据
    loadDtl() {
      this.$refs.dataView.fetchData()
    },
    // 菜单激活
    menuActiveCall() {
      if (this.$route.query && this.$route.query.id) {
        this.idQuery = this.$route.query.id
        const wrapper = this.$newWrapper().eq('id', this.idQuery)
        this.$refs.dataView.setQueryWrapperOnce(wrapper)
        return
      }
      this.loadDtl()
    },
    // 数据加载后
    afterLoad() {
      if (this.idQuery) {
        this.$refs.dataView.viewRow(this.idQuery)
        this.idQuery = ''
      }
    },
    // 过滤显示按钮
    filterBtn(btnList) {
      return btnList.filter(btn => !['vb-add'].includes(btn.code))
    }
  },
  mounted() {
    if (!this.propParent) {
      return
    }
    this.propParent.menuActiveCall = this.menuActiveCall
  }
}
</script>
